Skip to content

Make it possible to skip cbor2 tests#748

Merged
Tinche merged 4 commits into
python-attrs:mainfrom
mgorny:cbor2-optional
May 2, 2026
Merged

Make it possible to skip cbor2 tests#748
Tinche merged 4 commits into
python-attrs:mainfrom
mgorny:cbor2-optional

Conversation

@mgorny

@mgorny mgorny commented May 2, 2026

Copy link
Copy Markdown
Contributor

Now that cbor2 has been rewritten in Rust and the fallback Python implementation was removed, it is no longer possible to use it on all architectures where cattrs are used. Move the cbor2 imports into specific tests, so that the test suite can be run again, while skipping the handful of tests that actually need it.

Now that `cbor2` has been rewritten in Rust and the fallback Python
implementation was removed, it is no longer possible to use it on all
architectures where cattrs are used.  Move the `cbor2` imports into
specific tests, so that the test suite can be run again, while skipping
the handful of tests that actually need it.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
@mgorny

mgorny commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

I've aimed at a minimal change here. If you prefer something more elaborate, please let me know.

@Tinche

Tinche commented May 2, 2026

Copy link
Copy Markdown
Member

Which platforms are giving you trouble?

If we do this, we should follow how we handle missing msgspec and orjson, with appropriate skipifs.

@mgorny

mgorny commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Which platforms are giving you trouble?

Alpha, ARM < v6, HPPA, some of RISC-v and SPRC configurations, i486.

If we do this, we should follow how we handle missing msgspec and orjson, with appropriate skipifs.

Sure, but what's "appropriate" here? msgspec and orjson are skipped on PyPy right now.

@Tinche

Tinche commented May 2, 2026

Copy link
Copy Markdown
Member

Maybe we can try importing cbor2 and set the flag if it fails?

@mgorny

mgorny commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Sure. Do you want me to adjust the other tests to match? I can also cover the remaining optional dependencies, if you want.

mgorny added 2 commits May 2, 2026 15:40
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
@Tinche

Tinche commented May 2, 2026

Copy link
Copy Markdown
Member

Let's leave the other tests. Please add a very short changelog entry (although I don't think this is super relevant for end users).

Why the __import__ call instead of just a good old import statement?

@mgorny

mgorny commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Why the import call instead of just a good old import statement?

So that import checks don't complain that we're importing cbor2 but not using it (directly).

Signed-off-by: Michał Górny <mgorny@gentoo.org>
@Tinche

Tinche commented May 2, 2026

Copy link
Copy Markdown
Member

Thanks!

@Tinche Tinche merged commit fa103d6 into python-attrs:main May 2, 2026
12 checks passed
@mgorny

mgorny commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!

@mgorny mgorny deleted the cbor2-optional branch May 3, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants